﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

using Ylh.Data;
using Ylh.ElvModel;
using Ylh.Enums;

namespace Ylh.ElvBLL
{
    public class ComRoleElvBLL
    {
        /// <summary>
        /// [ORM]根据角色编号获取当前的角色信息
        /// </summary>
        /// <param name="ConStr">连接字符串</param>
        /// <param name="RoleID">角色编号</param>
        /// <returns>数据集合</returns>
        public DataTable GetCompetenceByRoleID(string ConStr, string RoleID)
        {
            SqlWhere where = new SqlWhere();
            where.Info = new TbComRole() { RoleID = RoleID };
            return TbComRole.Select(where, ConStr);
        }

        /// <summary>
        /// 根据角色编号删除角色权限
        /// </summary>
        /// <param name="ConStr"></param>
        /// <param name="RoleID">角色编号</param>
        /// <returns></returns>
        public bool DeleteComByRole(string ConStr, String RoleID)
        {
            TbComRole Role = new TbComRole();
            OQLWhere where = new OQLWhere(Role);
            where.AND(Role.RoleID, OperateType.等于, RoleID);
            return TbComRole.Delete(where, ConStr);
        }


        /// <summary>
        /// 插入权限关联
        /// </summary>
        /// <param name="ConStr">连接字符串</param>
        /// <param name="RoleID"></param>
        /// <param name="ComID"></param>
        /// <returns>是否插入成功</returns>
        public bool InsertCom(string ConStr, string RoleID, string ComID)
        {
            TbComRole Role = new TbComRole();
            Role.RoleID = RoleID;
            Role.CompetenceID = ComID;
            return  TbComRole.InserObjedct(Role, ConStr);
        }
    }
}
